<!doctype html>
<html>

<head>
  <!-- css文件 -->
  {include file="public/title" /}
</head>

<body data-type="generalComponents">
  <!-- 头部 -->
  {include file="public/header" /}
  <div class="tpl-page-container tpl-page-header-fixed">
    <!-- 左侧导航 -->
    {include file="public/leftNav" /}
    <div class="tpl-content-wrapper">
      <ol class="am-breadcrumb">
        <li><a href="#" class="am-icon-home">首页</a></li>
        <li><a href="#">管理员</a></li>
        <li class="am-active">用户组添加</li>
      </ol>
      <div class="tpl-portlet-components">
        <div class="tpl-block">
          <div class="am-g tpl-amazeui-form">
            <div class="am-u-sm-12 am-u-md-9">
              <form class="am-form am-form-horizontal" id="form_ajax" onsubmit="return false">
                <input type="hidden" name="id" value="{$AuthGroup.id}">
                <div class="am-form-group">
                  <label for="user-name" class="am-u-sm-3 am-form-label">用户组名 / Name</label>
                  <div class="am-u-sm-9">
                    <input type="text" name="title" id="user-name" value="{$AuthGroup.title}">
                  </div>
                </div>
                <div class="am-form-group">
                  <label for="user-mima" class="am-u-sm-3 am-form-label">是否启用</label>
                  <div class="am-u-sm-9">
                      <input type="checkbox" {if condition="$AuthGroup['status'] eq 1"}checked{/if} value="1" name="status" data-am-switch />
                  </div>
                </div>
                <div class="am-form-group">
                  <label for="user-intro" class="am-u-sm-3 am-form-label">描述</label>
                  <div class="am-u-sm-9">
                      <ul class="tpl-task-list" style="height:500px; overflow-y:auto;">
                        {foreach $AuthRule as $vo}
                          <li>
                            <div style="float: left;">
                              <?php echo str_repeat('&nbsp;',$vo['level']*5);?>
                            </div>
                            <div class="task-checkbox">
                              <input name="rules[]" value="{$vo.id}" <?php $arr=explode(',',$AuthGroup['rules']); if(in_array($vo['id'],$arr)){echo 'checked';} ?> type="checkbox" dataid="id-{$vo.dataid}" class="liChild checkbox-parent <?php if($vo['level']!=0){echo 'checkbox-child';}?>">
                            </div>
                            <div class="task-title">
                              <span class="task-title-sp" {if condition="$vo['level'] eq 0"}style="font-weight:700;"{/if}> {$vo.title} </span>
                            </div>
                          </li>
                        {/foreach}
                      </ul>
                  </div>
                </div>
                <div class="am-form-group">
                  <div class="am-u-sm-9 am-u-sm-push-3">
                    <button type="submit" id="submitFrom" class="am-btn am-btn-primary">修改</button>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- js -->
  {include file="public/foot" /}
  <script>
    $('#submitFrom').click(function(){
      var formData = $('#form_ajax').serialize();
      $.ajax({
        url:"{:url('AuthGroup/edit')}",
        type:'POST',
        data:formData,
        success:function(data){
          if(data.code == 1){
            layer.alert(data.msg, {icon: 6});
          }else{
            layer.alert(data.msg, {icon: 5});
          }
        }
      })
    })
  </script>
</body>
</html>